#include "..\examples\src\shared\gltools.h"

void RenderScene()
{
	GLfloat y;
	GLfloat fSize[2];
	GLfloat fCurSize;

	glClear(GL_COLOR_BUFFER_BIT);

	glGetFloatv(GL_LINE_WIDTH_RANGE, fSize);
	
	fCurSize = fSize[0];

	for (y = -90.0f; y < 90.0f; y += 20.0f)
	{
		glLineWidth(fCurSize);

		glBegin(GL_LINES);
			
			glVertex2f(-80.0f, y);
			glVertex2f(80.0f, y);

		glEnd();

		fCurSize += 1.0f;
	}

	glFlush();
}

void SetupRC()
{
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f );
	glColor3f(0.0f, 1.0f, 0.0f);
}

void ChangeSize(int w, int h)
{
	GLfloat nRange = 100.0f;

	if(h == 0)
		h = 1;

    glViewport(0, 0, w, h);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

    if (w <= h) 
		glOrtho (-nRange, nRange, -nRange*h/w, nRange*h/w, -nRange, nRange);
    else 
		glOrtho (-nRange*w/h, nRange*w/h, -nRange, nRange, -nRange, nRange);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
}

int main(int argc, char* argv[])
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
	glutCreateWindow("linesw");
	glutReshapeFunc(ChangeSize);
	glutDisplayFunc(RenderScene);
	SetupRC();
	glutMainLoop();

	return 0;
}
